﻿using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using BGShell.Interop;

namespace BGShell.Components
{
    public static class RedrawHelper
    {
        public static void SetRedrawRecursively(Control control, bool redraw)
        {
            SetRedraw(control, redraw);

            foreach (Control ctl in control.Controls)
            {
                SetRedrawRecursively(ctl, redraw);
            }
        }


        public static void SetRedraw(Control control, bool redraw)
        {
            NativeMethods.SendMessage(
                new HandleRef(control, control.Handle),
                WindowMessages.WM_SETREDRAW,
                redraw ? new IntPtr(1) : IntPtr.Zero,
                IntPtr.Zero);
        }
    }
}
